home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / wnx1091.lzh / START.S < prev    next >
Text File  |  1991-10-15  |  12KB  |  471 lines

  1. DEBUG    EQU     0        1 = Debugging, 0 = Final Revision
  2.     IFEQ    DEBUG
  3.         OPT    O+,W-,X-
  4.     ELSEIF
  5.         OPT    O+,W-,X+
  6.     ENDC
  7. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  8. WNX=0                0 if can run as WNX, otherwise not!
  9. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* MACROS -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  10. object        macro
  11.  
  12.         move.w    \2,\4
  13.         mulu    #ob_sizeof,\4
  14.         lea    0(\1,\4),\3
  15.         
  16.         endm
  17. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  18.         RSRESET
  19. ob_next        rs.w    1
  20. ob_head        rs.w    1
  21. ob_tail        rs.w    1
  22. ob_type        rs.w    1
  23. ob_flags    rs.w    1
  24. ob_state    rs.w    1
  25. ob_spec        rs.l    1
  26. ob_x        rs.w    1
  27. ob_y        rs.w    1
  28. ob_w        rs.w    1
  29. ob_h        rs.w    1
  30. ob_sizeof    rs.w    0
  31. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  32.         RSRESET
  33. dta_reserved    rs.b    21
  34. dta_attrib    rs.b    1
  35. dta_time    rs.b    2
  36. dta_date    rs.b    2
  37. dta_size    rs.b    4
  38. dta_name    rs.b    13
  39. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  40.         RSRESET
  41. MAGIC        rs.w    1
  42.  
  43. TSIZE        rs.l    1
  44. DSIZE        rs.l    1
  45. BSIZE        rs.l    1
  46. SSIZE        rs.l    1
  47.  
  48. SELFRESERVED    rs.w    5    
  49. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  50.         include    d:\wnx_dev\gemmacro.s
  51.         include    d:\wnx_dev\newmacro.s
  52.         include    d:\wnx_dev\xesmacro.s
  53.         *include    d:\wnx_dev\linea.s
  54. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* START *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  55. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  56. START
  57.         lea    START,a5        get the address of this code
  58.         tst.l    -220(a5)        is p_parent = 0?
  59.         cmp.l    #"XES",-216(a5)        is p_reserved = "XES"
  60.         beq.s    start_wnx        no, so do .PRG startup code
  61.  
  62.         move.l    a0,d0            
  63.         tst.l    d0            is a0 <> 0?
  64.         bne    start_acc        yes, so .ACC!
  65.         bra    start_prg        no, so .PRG...        
  66.  
  67. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  68. start_wnx
  69.     IFEQ    WNX = 0
  70. * first, make a call to initialize.  Pass the address of your RSC.
  71.         move.w    #-1,app            app = -1 for WNXes
  72.         xes_init    #parmblk
  73.  
  74.         move.w    WNX_grafhandle,current_handle
  75.  
  76.         xes_rsrcinit    #-1,#2,#resource1
  77.         move.l    WNX_out+6,a0        got the address!
  78.         move.l    a0,treeptr
  79.         move.l    (a0),rsrcptr
  80.  
  81.         xes_genv            get screen settings...
  82.         move.w    WNX_out+12,scalex
  83.         move.w    WNX_out+14,scaley
  84.         
  85.         xes_pwindow            get window settings...
  86.         movem.w    WNX_out+8,d4-d7
  87.         movem.w    d4-d7,minx
  88.  
  89.         move.w    #%000000,WNX_flags
  90.         *move.w    #0001,WNX_tcount
  91.         *move.l    #maintimer,WNX_troutine
  92.         *move.l    #mainbutton,WNX_broutine
  93.         *move.l    #mainbutton,tempbutton
  94.         *move.l    #mainmessage,WNX_mroutine
  95.         *move.l    #mainredraw,WNX_rroutine
  96.         move.l    #termroutine,WNX_termroutine
  97.         xes_submit
  98.     ELSEIF
  99.         form_alert    #1,#cannotrunaswnx
  100.  
  101.         move.l    #START-358,-(a7)    ptr to default parmblk
  102.         move.w    #39,-(a7)
  103.         xes_call
  104.         
  105.     ENDC
  106.  
  107. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  108. start_prg    
  109.  
  110.         move.w    #1,app            PRGs,etc... have app = 1
  111.         move.l    4(a7),a3        base page
  112.         move.l    #mystack,a7
  113.         move.l    $c(a3),d0        text len
  114.         add.l    $14(a3),d0        data len
  115.         add.l    $1c(a3),d0        BSS len
  116.         add.l    #$100,d0        basepage
  117.  
  118.         move.l    d0,-(sp)
  119.         move.l    a3,-(sp)
  120.         clr.w    -(sp)
  121.         move.w    #$4a,-(sp)
  122.         trap    #1            shrink memory
  123.         lea    12(sp),sp
  124.  
  125.         bra.s    go_prg_or_acc
  126. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  127. start_acc    
  128.         move.w    #0,app            ACCs have app = 0
  129.         move.l    #mystack,a7        must have a stack!
  130.  
  131. go_prg_or_acc    dc.w    $a000            line-A init
  132.         move.l    a0,a_init        
  133.  
  134.         appl_init
  135.         move.w    d0,ap_id        store the application id
  136.  
  137.         graf_handle
  138.         move.w    d0,current_handle    Desktop's VDI handle
  139.  
  140.         bsr    get_scalexy
  141.  
  142.         move.w    #2,rsc_scale_flag
  143.         move.l    #resource1,d1
  144.         bsr    rsrc_include
  145.         move.l    result0,rsrcptr
  146.  
  147.         tst.w    app            program or accessory?
  148.         bne.s    go_prg            program!
  149.         
  150.         menu_register    ap_id,#mymenu
  151.         jmp    auto_acc
  152. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  153. go_prg
  154. * start by opening a virtual workstation
  155.         lea    intin,a0
  156.         moveq    #10-1,d0        -1 for DBF
  157. .fill        move.w    #1,(a0)+        most params are 1
  158.         dbf    d0,.fill
  159.         move.w    #2,(a0)+        use RC system
  160.  
  161.         v_opnvwk            open it
  162.         
  163.         wind_get    #0,#4        find working area...
  164.         movem.w    int_out+2,d0-d3
  165.         movem.w    d0-d3,minx
  166.  
  167. * gets the resolution of the system!
  168.         _getrez
  169.         move.w    d0,origmode
  170.  
  171.         _physbase
  172.         move.l    d0,orig1
  173.         
  174.         _logbase
  175.         move.l    d0,orig2
  176.  
  177. * set the mouse to an arrow
  178.         graf_mouse    #0
  179.         jmp    PROGRAM
  180. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  181. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- MAIN *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  182. auto_acc
  183. * Any autoboot DA code goes here...
  184. * We conclude by getting into the accessory loop in wait4event...
  185. * load the RSC
  186. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  187. wait4event
  188. * We wait for GEM to say this DA is open...
  189.         evnt_mesag    #messagebuf    
  190.         move.l        #messagebuf,a0
  191.         move.w        (a0),d0
  192.         cmp.w        #40,d0
  193.         beq        BEGIN
  194.  
  195. * check for other GEM messages here...
  196.         bra.s        wait4event
  197. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  198. get_scalexy
  199.         vqt_fontinfo
  200.         movem.w    int_out+2,d0-d1
  201.  
  202. * fixes MultiDesk incompatibility by sensing when 6x6 font is in!
  203. ._h        divu.w    #8,d0
  204.         bne    ._w
  205.  
  206.         moveq    #1,d0
  207.         
  208. ._w        divu.w    #8,d1
  209.         bne    ._done
  210.         
  211.         moveq    #1,d1
  212.         
  213. ._done        movem.w    d0-d1,scalex
  214.  
  215.         rts
  216. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  217. rsc_scale_flag    dc.l    0
  218. result0        dc.l    0
  219. result1        dc.l    0
  220. result2        dc.l    0
  221. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  222. rsrc_include
  223. * fixes up a resource tree using mystic arts.  Actually fixes multiple
  224. * resource trees within one .RSC file!
  225. * in:    d1 = ptr to binary .RSC file in memory.
  226. *
  227. * out:    result0 = ptr to first tree in resource.
  228. *    result1    = ptr to tree list.
  229. *    result2 = number of trees in resource.
  230. *
  231. * assume to smash all registers.
  232. *
  233.  
  234.         tst.l    d1
  235.         beq.w    rsrc_null
  236.         
  237.         move.l    d1,a2            a2 = ptr to binary RSC
  238.         move.l    d1,d7            d7 = a2
  239.         
  240.         move.w    20(a2),d2        d2 = number of objects in RSC
  241.         subq.w    #1,d2            d2 = d2 - 1
  242.  
  243.         moveq    #0,d0        
  244.         move.w    2(a2),d0        d0 = offset to first tree
  245.         add.l    d0,a2            a2 = ptr to first tree...
  246.  
  247.         move.l    a2,result0        result0 = ptr to first tree |X|
  248.         
  249. fixloop
  250.         object    a2,d2,a0,d0
  251.         move.w    ob_type(a0),d0        d0 = object type
  252.         move.l    ob_spec(a0),d1        d1 = object spec field.
  253.         
  254.         cmp.w    #20,d0
  255.         beq.s    endfixloop
  256.         cmp.w    #25,d0
  257.         beq.s    endfixloop
  258.         cmp.w    #27,d0
  259.         beq.s    endfixloop
  260.         
  261.         add.l    d7,d1
  262.         move.l    d1,ob_spec(a0)        fixes up ob_spec entry
  263.         
  264.         move.l    d1,a1
  265.         add.l    d7,(a1)+        fixes up a field
  266.         
  267.         cmp.w    #23,d0
  268.         beq.s    endfixloop
  269.         cmp.w    #24,d0
  270.         beq.s    endfixloop
  271.         
  272.         add.l    d7,(a1)+        fixes up two fields...
  273.         add.l    d7,(a1)+
  274.  
  275. endfixloop
  276.         lea    16(a0),a0        point at X field
  277.         
  278.         move.w    scalex,d0        scale of x to 8x8 font
  279.         move.w    scaley,d1        scale of y to 8x8 font
  280.  
  281.         move.w    #1,d6            fix (1+1)*2 entries (X,Y,W,H)
  282.         
  283. fix_XYWH        
  284. .XW        moveq    #0,d4
  285.         moveq    #0,d5
  286.         move.b    (a0),d4            d4 = 0-7 pixel coord
  287.         
  288.         tst.w    rsc_scale_flag        scale pixel coords?
  289.         beq.s    .skip1            no.
  290.  
  291.         mulu    d0,d4            d4 = d4 * d0 if flag set.
  292.         
  293. .skip1        move.b    1(a0),d5        d5 = char coord
  294.         mulu    #8,d5
  295.         
  296.         cmp.w    #2,rsc_scale_flag    scale char coords?
  297.         bne.s    .skip1b            no.
  298.         
  299.         mulu    d0,d5            d5 = d5 * d0 if flag set.
  300.         
  301. .skip1b        add.w    d4,d5
  302.         move.w    d5,(a0)+
  303.  
  304.  
  305. .YH        moveq    #0,d4
  306.         moveq    #0,d5
  307.         move.b    (a0),d4            0-7 pixel coord
  308.         
  309.         tst.w    rsc_scale_flag        if not set, no conversion
  310.         beq.s    .skip2            
  311.  
  312.         mulu    d1,d4            d4 = d4 * d0 if flag set
  313.         
  314. .skip2        move.b    1(a0),d5        d5 = char coord
  315.         mulu    #8,d5
  316.  
  317.         cmp.w    #2,rsc_scale_flag    scale char coords?
  318.         bne.s    .skip2b            no.
  319.     
  320.         mulu    d1,d5
  321.  
  322. .skip2b        add.w    d4,d5
  323.         
  324.         move.w    d5,(a0)+
  325.         
  326.         dbra.w    d6,fix_XYWH
  327.         
  328.         dbra.w    d2,fixloop        keep fixin' 'em!
  329.         
  330. fixtrees    move.l    d7,a0            a0 = ptr to binary resource
  331.         move.w    22(a0),d6        d6 = number of trees
  332.         move.w    d6,result2        result2.W = number of trees |X|
  333.         
  334.         move.l    d7,a1            a1 = d7 = a0
  335.         moveq    #0,d0
  336.         move.w    18(a0),d0        d0 = offset to tree entries
  337.         add.l    d0,a1            a1 = ptr to tree entries
  338.         move.l